package com.sita.tboard.global;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

import com.sita.bike.support.GlobalContext;
import com.sita.tboard.ui.tools.L;

/**
 * Created by xiaodong on 16/3/28.
 */
public class LocalConstants {
    public static final int RT_RESOURCE_LOADER = 1;
    public static final int RT_NOTE_LOADER = 2;

    public static final String BIND_RESOURCE_ID = "RESOURCE_ID";
    public static final String BUNDLE_ACCOUNT_ID = "ACCOUNT_ID";

    private static String HITCHHIKE_ENABLED;

    public static boolean isHitchhikeEnabled() {
        if (HITCHHIKE_ENABLED == null) {
            try {
                ApplicationInfo appInfo = GlobalContext.getGlobalContext().getPackageManager()
                        .getApplicationInfo(GlobalContext.getGlobalContext().getPackageName(),
                                PackageManager.GET_META_DATA);
                HITCHHIKE_ENABLED = appInfo.metaData.getString("HITCHHIKE_ENABLED", "disable");

                L.i("readMetaDataFromApplication()", "HITCHHIKE_ENABLED=" + HITCHHIKE_ENABLED);
                return HITCHHIKE_ENABLED.equals("enable");
            } catch (PackageManager.NameNotFoundException e) {
                L.e("readMetaDataFromApplication()", e);
                return false;
            }
        } else {
            return HITCHHIKE_ENABLED.equals("enable");
        }
    }
}
